package com.sxhuayuan.parking.dto;

import java.io.Serializable;
import java.math.BigDecimal;
import java.util.Date;

import com.alibaba.fastjson.annotation.JSONField;
import com.sxhuayuan.parking.utils.SettingUtils;

import lombok.Getter;
import lombok.Setter;

/**
 * 缓存停车费用的信息封装
 * 
 * @author gy
 */
@Setter
@Getter
public class ParkFeeCacheBean implements Serializable {
	private static final long serialVersionUID = 2907954705806368292L;

	private String parkPluginId;
	private Long uniqueId;
	private String carPlate;
	private String exitDevice;// 2选1
	private Long exitId;// 2选1
	// 自费截止时间
	@JSONField(format = "yyyyMMddHHmmss")
	private Date endTime;
	// 车场订单号
	private String lotOrderNo;
	// 车费总计(未减去优惠金额)
	private Float totalFee;
	// 优惠金额
	private Float discountFee;

	/**
	 * 获取应付金额
	 */
	@JSONField(serialize = false)
	public BigDecimal getPayable() {
		BigDecimal _discountFee = discountFee == null ? BigDecimal.ZERO : new BigDecimal(discountFee);
		return SettingUtils.get().setScale(new BigDecimal(totalFee).subtract(_discountFee));
	}

	/** 获取优惠金额 */
	@JSONField(serialize = false)
	public BigDecimal getDiscount() {
		BigDecimal _discountFee = discountFee == null ? BigDecimal.ZERO : new BigDecimal(discountFee);
		return SettingUtils.get().setScale(_discountFee);
	}
}
